# Apply a Project Template to an existing Workspace

Applies a template to an existing project.
This endpoint returns structured Workspace objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the `results` array
and will be indexed by ID in the `workspaces` top-level JSON key.
Please see our [Response Format](#section/Response-Format) section for more information.

Endpoint: PUT /workspaces/{id}/apply_template
Version: 1.0.0

## Path parameters:

  - `id` (integer, required)
    The ID of the Model.

## Query parameters:

  - `edit_stories` (boolean)
    If `true`, the project participants and unnamed resources specified in the request body
will be added to the project, but the template tasks will not actually be created in the
project. Instead, `template_stories_json` will be returned in the response, containing
information about the template tasks and assignments.

  - `include` (string)
    Any of the below associations can be included in your request by providing the `include` param, e.g. `include=association1,association2`.
- `account_color` (AccountColor) - Retrieves the color of the workspace. The response will include `account_color_id`, which references the data in the `account_colors` top-level key.
- `account_insights_mappings` (AccountInsightsMapping) - Retrieves the Insights dynamic dashboards in the workspace. The response will include `account_insights_mapping_ids`, which references the data in the `account_insights_mappings` top-level key.
- `approver` (User) - Retrieves the first approver (as determined by user ID) on the workspace who is viewable to the current user. The response will include `approver_id`, which references the data in the `users` top-level key.
- `approvers` (User) - Retrieves all time approvers on the workspace who are viewable to the current user. The response will include `approver_ids`, which references the data in the `users` top-level key.
- `billing_milestones` (BillingMilestone) - Retrieves the billing milestones for the workspace. The response will include `billing_milestone_ids`, which references the data in the `billing_milestones` top-level key.
- `creator` (User) - Retrieves the user who created the project. The response will include `creator_id`, which references the data in the `users` top-level key. If the creator has left the project, you can use `primary_counterpart` to get the provider-side team lead.
- `current_status_report` (StatusReport) - Retrieves the most recent project status report from today. The response will include `current_status_report_id`, which references the data in the `status_reports` top-level key.
- `current_user_participation` (Participation) - Retrieves the workspace participation of the current user. The response will include `current_user_participation_ids`, which references the data in the `participations` top-level key.
- `custom_field_values` (CustomFieldValue) - Retrieves custom field values for the workspace. The response will include `custom_field_value_ids`, which references the data in the `custom_field_values` top-level key.
- `external_references` (ExternalReference) - Includes references to external integrations for this object.
- `financial_viewers` (User) - Retrieves the users on the project who have financial access. The response will include `financial_viewer_ids`, which references the data in the `users` top-level key.
- `next_uncompleted_milestone` (Story) - Retrieves the next project milestone that is not complete. The response will include `next_uncompleted_milestone_id`, which references the data in the `stories` top-level key.
- `participants` (User) - Retrieves users that are participating in the project. The response will include `participant_ids`, which references the data in the `users` top-level key.
- `participations` (Participation) - Retrieves the [participations](/tag/Participations) of each participant in the project. The response will include `participation_ids`, which references the data in the `participations` top-level key.
- `possible_approvers` (User) - Retrieves the users that can be made time approvers on the workspace. The response will include `possible_approver_ids`, which references the data in the `users` top-level key.
- `primary_counterpart` (User) - Retrieves the lead of the Clients team. The response will include `primary_counterpart_id`, which references the data in the `users` top-level key.
- `primary_maven` (User) - Retrieves the lead of the Providers team. The response will include `primary_maven_id`, which references the data in the `users` top-level key.
- `primary_workspace_group` (WorkspaceGroup) - Retrieves the primary group associated with the project. The response will include `primary_workspace_group_id`, which references the data in the `workspace_groups` top-level key.
- `status_reports` (StatusReport) - Retrieves the status reports for the workspace. The response will include `status_report_ids`, which references the data in the `status_reports` top-level key.
- `timesheet_submissions` (TimesheetSubmission) - Retrieves the list of all submitted timesheets which the user can approve on the project. The response will include `timesheet_submission_ids`, which references the data in the `timesheet_submissions` top-level key.
- `workspace_groups` (WorkspaceGroup) - Retrieves groups associated with the project that is visible to the current user. The response will include `workspace_group_ids`, which references the data in the `workspace_groups` top-level key.
- `workspace_resources` (WorkspaceResource) - Retrieves the named resources for the workspace. The response will include `workspace_resource_ids`, which references the data in the `workspace_resources` top-level key.
- `workspace_resources_with_unnamed` (WorkspaceResource) - Retrieves the named and unnamed resources for the workspace. The response will include `workspace_resources_with_unnamed_ids`, which references the data in the `workspace_resources` top-level key.

  - `optional_fields` (array)
    Allows you to request one or more optional fields as an array.

## Request fields (application/json):

  - `workspace` (object)

  - `workspace.project_tracker_template_id` (integer)
    The ID of the template to use to populate tasks and other information in the project.

  - `workspace.project_template_weekends_as_workdays` (boolean)
    Whether weekends count as work days when applying the template. If `true`, weekend days will be included in task durations.

  - `workspace.project_template_start_date` (string)
    The start date that tasks will be based on when the template is applied. The date must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `workspace.project_template_checklist_as_todos` (boolean)
    Whether checklist items are converted to To Dos when applying the template.

  - `workspace.project_template_create_unnamed_resources` (boolean)
    If `true`, all template resources and task assignments will be mapped to unnamed
resources and `project_template_assignment_mappings` will be ignored.

  - `workspace.project_template_distribute_hours` (boolean)
    Whether task estimated hours in the template are automatically added as scheduled hours
for all tasks when applying the template. The hours will be distributed evenly between
the task start date and end date.

  - `workspace.project_template_assignment_mappings` (array)
    This maps template resources to named or unnamed resources when the template is applied.

  - `workspace.project_template_assignment_mappings.role_id` (integer)
    The ID of the account role to use as the workspace role for this template resource. If you pass a `role_id` but do not pass a `user_id`, an unnamed resource will be created.

  - `workspace.project_template_assignment_mappings.user_id` (integer)
    The ID of the user to map the template resource to. If you pass a `user_id` and do not set `role_id`, the workspace resource's role will be the user's default account role or—if they have none—it will be blank.

  - `workspace.project_template_assignment_mappings.resource_id` (integer)
    The ID of the [project template assignment](/tag/Project-Template-Assignments) this mapping is for.

  - `workspace.project_template_assignment_mappings.create_unnamed_resource` (boolean)
    If this is `true` and no `user_id` is specified, a new unnamed resource will be created for this template resource using the specified role, and the tasks will be assigned to the unnamed resource.

  - `workspace.project_template_before_story_id` (integer)
    The ID of an existing task the template tasks should be inserted after. The provided task ID must belong to a top-level task.

## Response 200:

  - `200` (unknown)
    Workspace has been updated.

## Response 200 fields (application/json):

  - `count` (integer)

  - `meta` (object)

  - `meta.count` (integer)

  - `meta.page_count` (integer)

  - `meta.page_number` (integer)

  - `meta.page_size` (integer)

  - `results` (array)

  - `results.key` (string)

  - `results.id` (string)

  - `workspaces` (object)

  - `external_references` (object)

  - `stories` (object)

  - `users` (object)

  - `participations` (object)

  - `timesheet_submissions` (object)

  - `workspace_groups` (object)

  - `custom_field_values` (object)

  - `workspace_resources` (object)

  - `status_reports` (object)

  - `account_colors` (object)

  - `account_insights_mappings` (object)

  - `billing_milestones` (object)

## Response 400:

  - `400` (unknown)
    Bad Request

## Response 400 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 401:

  - `401` (unknown)
    Unauthorized request

## Response 401 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 403:

  - `403` (unknown)
    Forbidden request

## Response 403 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 404:

  - `404` (unknown)
    Page Not Found

## Response 404 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 422:

  - `422` (unknown)
    Unprocessable Entity

## Response 422 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 503:

  - `503` (unknown)
    Service is unavailable

## Response 503 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

